<?php
/**
 * @version		0.2.0 joomla zmluvy $
 * @package		com_zjmluvy
 * @copyright	Copyright © 2011 - All rights reserved.
 * @license		GNU/GPL
 * @author    AdrianKo		
 * @website   http://code.google.com/p/joomla-zmluvy
 *
 *
 *1.3.2012
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

class upravakategorie extends JTable
{
	/**
	 * Primary Key
	 * @var int
	 */
	var $id 				= null;
	/** @var string */
	var $title 				= '';
	/** @var string */
	var $description 				= '';
	/** @var int */
	var $published	 			= '';
	/** @var int */
//	var $checked_out 		= 0;
	/** @var date */
//	var $checked_out_time 	= 0;

	function upravakategorie(& $db) {
		parent::__construct('#__jzmluvy_kategorie', 'id', $db);
	}

	// overloaded check function
	function check()
	{
/*		// Check fields
		if (empty($this->enddates)) {
			$this->enddates = NULL;
		}

		if (empty($this->times)) {
			$this->times = NULL;
		}

		if (empty($this->endtimes)) {
			$this->endtimes = NULL;
		}

		$this->title = strip_tags(trim($this->title));
		$titlelength = JString::strlen($this->title);

		if ( $this->title == '' ) {
			$this->_error = JText::_( 'ADD TITLE' );
      		JError::raiseWarning('SOME_ERROR_CODE', $this->_error );
      		return false;
		}

		if ( $titlelength > 100 ) {
      		$this->_error = JText::_( 'ERROR TITLE LONG' );
      		JError::raiseWarning('SOME_ERROR_CODE', $this->_error );
      		return false;
		}*/

		$alias = JFilterOutput::stringURLSafe($this->title);

		if(empty($this->alias) || $this->alias === $alias ) {
			$this->alias = $alias;
		}

		/*if (!preg_match("/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/", $this->dates)) {
	      	$this->_error = JText::_( 'DATE WRONG' );
	      	JError::raiseWarning('SOME_ERROR_CODE', $this->_error );
	      	return false;
		}

		if (isset($this->enddates)) {
			if (!preg_match("/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/", $this->enddates)) {
				$this->_error = JText::_( 'ENDDATE WRONG FORMAT');
				JError::raiseWarning('SOME_ERROR_CODE', $this->_error );
				return false;
			}
		}

		if (isset($this->recurrence_counter)) {
			if (!preg_match("/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/", $this->recurrence_counter)) {
	 		     	$this->_error = JText::_( 'DATE WRONG' );
	 		     	JError::raiseWarning('SOME_ERROR_CODE', $this->_error );
	 		     	return false;
			}
		}

		if (isset($this->times)) {
   			if (!preg_match("/^[0-2][0-9]:[0-5][0-9]$/", $this->times)) {
      			$this->_error = JText::_( 'TIME WRONG' );
      			JError::raiseWarning('SOME_ERROR_CODE', $this->_error );
      			return false;
	  		}
		}

		if (isset($this->endtimes)) {
   			if (!preg_match("/^[0-2][0-9]:[0-5][0-9]$/", $this->endtimes)) {
      			$this->_error = JText::_( 'TIME WRONG' );
      			JError::raiseWarning('SOME_ERROR_CODE', $this->_error );
      			return false;
	  		}
		}

		//No venue or category choosen?
/*		if($this->locid == '') {
			$this->_error = JText::_( 'VENUE EMPTY');
			JError::raiseWarning('SOME_ERROR_CODE', $this->_error );
			return false;
		} */

/*		if($this->catsid == 0) {
			$this->_error = JText::_( 'CATEGORY EMPTY');
			JError::raiseWarning('SOME_ERROR_CODE', $this->_error );
			return false;
		}*/

		return true;
	}
}
?>